<?php

class HomepageHelper extends myHelper{

	/*
	   return array( 0 => array(news' => Doctrine_Collection news, 'node' -> Structure node));
	 */
	public function getSectionsNews(){
		return NewItemTable::normalizeAssociatedNews($this->getSectionsNewsQuery());
	}

	public function getSectionsNewsQuery(){
		$q =  NewItemTable::getStructureNewsQuery();
		
		$q->where($q->getRootAlias().'.lang = ?', $this->getAction()->getRoute()->getObject()->getLang())
			->andWhere($q->getRootAlias().'.parameter = ?', 'section')
			->andWhere($q->getRootAlias().'.isHidden = ?', false)
			->andWhere("ni.picture != ''")
			->orderBy('s.lft, ni.pri');

		NewItemTable::commonActivityConstraints($q);


		return $q;
	}

	public function getNodeSectionQuery(Structure $item){
			return Doctrine::getTable('Structure')->createQuery()
					->from('Structure s')
					->where('s.lft < ? and s.rgt > ? and s.level < ? and s.parameter = ?',
							array($item['lft'],$item['rgt'],$item['level'], 'section'));
	}

	



}